home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / interface / browser.swf / scripts / %3Cdefault package%3E / FUIComponentSymbol.as < prev   
Encoding:
Text File  |  2007-10-26  |  8.2 KB  |  301 lines

  1. function FUIComponentClass()
  2. {
  3.    this.init();
  4. }
  5. FUIComponentClass.prototype = new MovieClip();
  6. FUIComponentClass.prototype.init = function()
  7. {
  8.    this.enable = true;
  9.    this.focused = false;
  10.    this.useHandCursor = false;
  11.    this._accImpl = new Object();
  12.    this._accImpl.stub = true;
  13.    this.styleTable = new Array();
  14.    if(_global.globalStyleFormat == undefined)
  15.    {
  16.       _global.globalStyleFormat = new FStyleFormat();
  17.       globalStyleFormat.isGlobal = true;
  18.       _global._focusControl = new Object();
  19.       _global._focusControl.onSetFocus = function(oldFocus, newFocus)
  20.       {
  21.          oldFocus.myOnKillFocus();
  22.          newFocus.myOnSetFocus();
  23.       };
  24.       Selection.addListener(_global._focusControl);
  25.    }
  26.    if(this._name != undefined)
  27.    {
  28.       this._focusrect = false;
  29.       this.tabEnabled = true;
  30.       this.focusEnabled = true;
  31.       this.tabChildren = false;
  32.       this.tabFocused = true;
  33.       if(this.hostStyle == undefined)
  34.       {
  35.          globalStyleFormat.addListener(this);
  36.       }
  37.       else
  38.       {
  39.          this.styleTable = this.hostStyle;
  40.       }
  41.       this.deadPreview._visible = false;
  42.       this.deadPreview._width = this.deadPreview._height = 1;
  43.       this.methodTable = new Object();
  44.       this.keyListener = new Object();
  45.       this.keyListener.controller = this;
  46.       this.keyListener.onKeyDown = function()
  47.       {
  48.          this.controller.myOnKeyDown();
  49.       };
  50.       this.keyListener.onKeyUp = function()
  51.       {
  52.          this.controller.myOnKeyUp();
  53.       };
  54.       for(var _loc3_ in this.styleFormat_prm)
  55.       {
  56.          this.setStyleProperty(_loc3_,this.styleFormat_prm[_loc3_]);
  57.       }
  58.    }
  59. };
  60. FUIComponentClass.prototype.setEnabled = function(enabledFlag)
  61. {
  62.    this.enable = arguments.length <= 0 ? true : enabledFlag;
  63.    this.tabEnabled = this.focusEnabled = enabledFlag;
  64.    if(!this.enable && this.focused)
  65.    {
  66.       Selection.setFocus(undefined);
  67.    }
  68. };
  69. FUIComponentClass.prototype.getEnabled = function()
  70. {
  71.    return this.enable;
  72. };
  73. FUIComponentClass.prototype.setSize = function(w, h)
  74. {
  75.    this.width = w;
  76.    this.height = h;
  77.    this.focusRect.removeMovieClip();
  78. };
  79. FUIComponentClass.prototype.setChangeHandler = function(chng, obj)
  80. {
  81.    this.handlerObj = obj != undefined ? obj : this._parent;
  82.    this.changeHandler = chng;
  83. };
  84. FUIComponentClass.prototype.invalidate = function(methodName)
  85. {
  86.    this.methodTable[methodName] = true;
  87.    this.onEnterFrame = this.cleanUI;
  88. };
  89. FUIComponentClass.prototype.cleanUI = function()
  90. {
  91.    if(this.methodTable.setSize)
  92.    {
  93.       this.setSize(this.width,this.height);
  94.    }
  95.    else
  96.    {
  97.       this.cleanUINotSize();
  98.    }
  99.    this.methodTable = new Object();
  100.    delete this.onEnterFrame;
  101. };
  102. FUIComponentClass.prototype.cleanUINotSize = function()
  103. {
  104.    for(var _loc2_ in this.methodTable)
  105.    {
  106.       this[_loc2_]();
  107.    }
  108. };
  109. FUIComponentClass.prototype.drawRect = function(x, y, w, h)
  110. {
  111.    var _loc4_ = this.styleTable.focusRectInner.value;
  112.    var _loc5_ = this.styleTable.focusRectOuter.value;
  113.    if(_loc4_ == undefined)
  114.    {
  115.       _loc4_ = 16777215;
  116.    }
  117.    if(_loc5_ == undefined)
  118.    {
  119.       _loc5_ = 0;
  120.    }
  121.    this.createEmptyMovieClip("focusRect",1000);
  122.    this.focusRect.controller = this;
  123.    this.focusRect.lineStyle(1,_loc5_);
  124.    this.focusRect.moveTo(x,y);
  125.    this.focusRect.lineTo(x + w,y);
  126.    this.focusRect.lineTo(x + w,y + h);
  127.    this.focusRect.lineTo(x,y + h);
  128.    this.focusRect.lineTo(x,y);
  129.    this.focusRect.lineStyle(1,_loc4_);
  130.    this.focusRect.moveTo(x + 1,y + 1);
  131.    this.focusRect.lineTo(x + w - 1,y + 1);
  132.    this.focusRect.lineTo(x + w - 1,y + h - 1);
  133.    this.focusRect.lineTo(x + 1,y + h - 1);
  134.    this.focusRect.lineTo(x + 1,y + 1);
  135. };
  136. FUIComponentClass.prototype.pressFocus = function()
  137. {
  138.    this.tabFocused = false;
  139.    this.focusRect.removeMovieClip();
  140.    Selection.setFocus(this);
  141. };
  142. FUIComponentClass.prototype.drawFocusRect = function()
  143. {
  144.    this.drawRect(-2,-2,this.width + 4,this.height + 4);
  145. };
  146. FUIComponentClass.prototype.myOnSetFocus = function()
  147. {
  148.    this.focused = true;
  149.    Key.addListener(this.keyListener);
  150.    if(this.tabFocused)
  151.    {
  152.       this.drawFocusRect();
  153.    }
  154. };
  155. FUIComponentClass.prototype.myOnKillFocus = function()
  156. {
  157.    this.tabFocused = true;
  158.    this.focused = false;
  159.    this.focusRect.removeMovieClip();
  160.    Key.removeListener(this.keyListener);
  161. };
  162. FUIComponentClass.prototype.executeCallBack = function()
  163. {
  164.    this.handlerObj[this.changeHandler](this);
  165. };
  166. FUIComponentClass.prototype.updateStyleProperty = function(styleFormat, propName)
  167. {
  168.    this.setStyleProperty(propName,styleFormat[propName],styleFormat.isGlobal);
  169. };
  170. FUIComponentClass.prototype.setStyleProperty = function(propName, value, isGlobal)
  171. {
  172.    if(value == "")
  173.    {
  174.       return undefined;
  175.    }
  176.    var _loc17_ = parseInt(value);
  177.    if(!isNaN(_loc17_))
  178.    {
  179.       value = _loc17_;
  180.    }
  181.    var _loc16_ = arguments.length <= 2 ? false : isGlobal;
  182.    if(this.styleTable[propName] == undefined)
  183.    {
  184.       this.styleTable[propName] = new Object();
  185.       this.styleTable[propName].useGlobal = true;
  186.    }
  187.    if(this.styleTable[propName].useGlobal || !_loc16_)
  188.    {
  189.       this.styleTable[propName].value = value;
  190.       if(this.setCustomStyleProperty(propName,value))
  191.       {
  192.          addr79:
  193.          this.styleTable[propName].useGlobal = _loc16_;
  194.       }
  195.       else if(propName == "embedFonts")
  196.       {
  197.          this.invalidate("setSize");
  198.          ┬º┬ºgoto(addr79);
  199.       }
  200.    }
  201. };
  202. FUIComponentClass.prototype.registerSkinElement = function(skinMCRef, propName)
  203. {
  204.    if(this.styleTable[propName] == undefined)
  205.    {
  206.       this.styleTable[propName] = new Object();
  207.       this.styleTable[propName].useGlobal = true;
  208.    }
  209.    if(this.styleTable[propName].coloredMCs == undefined)
  210.    {
  211.       this.styleTable[propName].coloredMCs = new Object();
  212.    }
  213.    this.styleTable[propName].coloredMCs[skinMCRef] = skinMCRef;
  214.    if(this.styleTable[propName].value != undefined)
  215.    {
  216.       var _loc4_ = new Color(skinMCRef);
  217.       _loc4_.setRGB(this.styleTable[propName].value);
  218.    }
  219. };
  220. _global.FStyleFormat = function()
  221. {
  222.    this.nonStyles = {listeners:true,isGlobal:true,isAStyle:true,addListener:true,removeListener:true,nonStyles:true,applyChanges:true};
  223.    this.listeners = new Object();
  224.    this.isGlobal = false;
  225.    if(arguments.length > 0)
  226.    {
  227.       for(var _loc3_ in arguments[0])
  228.       {
  229.          this[_loc3_] = arguments[0][_loc3_];
  230.       }
  231.    }
  232. };
  233. _global.FStyleFormat.prototype = new Object();
  234. FStyleFormat.prototype.addListener = function()
  235. {
  236.    var _loc3_ = 0;
  237.    while(_loc3_ < arguments.length)
  238.    {
  239.       var _loc4_ = arguments[_loc3_];
  240.       this.listeners[arguments[_loc3_]] = _loc4_;
  241.       for(var _loc5_ in this)
  242.       {
  243.          if(this.isAStyle(_loc5_))
  244.          {
  245.             _loc4_.updateStyleProperty(this,_loc5_.toString());
  246.          }
  247.       }
  248.       _loc3_ = _loc3_ + 1;
  249.    }
  250. };
  251. FStyleFormat.prototype.removeListener = function(component)
  252. {
  253.    this.listeners[component] = undefined;
  254.    for(var _loc4_ in this)
  255.    {
  256.       if(this.isAStyle(_loc4_))
  257.       {
  258.          if(component.styleTable[_loc4_].useGlobal == this.isGlobal)
  259.          {
  260.             component.styleTable[_loc4_].useGlobal = true;
  261.             var _loc3_ = !this.isGlobal ? globalStyleFormat[_loc4_] : undefined;
  262.             component.setStyleProperty(_loc4_,_loc3_,true);
  263.          }
  264.       }
  265.    }
  266. };
  267. FStyleFormat.prototype.applyChanges = function()
  268. {
  269.    var _loc6_ = 0;
  270.    for(var _loc5_ in this.listeners)
  271.    {
  272.       var _loc3_ = this.listeners[_loc5_];
  273.       if(arguments.length > 0)
  274.       {
  275.          var _loc4_ = 0;
  276.          while(_loc4_ < arguments.length)
  277.          {
  278.             if(this.isAStyle(arguments[_loc4_]))
  279.             {
  280.                _loc3_.updateStyleProperty(this,arguments[_loc4_]);
  281.             }
  282.             _loc4_ = _loc4_ + 1;
  283.          }
  284.       }
  285.       else
  286.       {
  287.          for(_loc4_ in this)
  288.          {
  289.             if(this.isAStyle(_loc4_))
  290.             {
  291.                _loc3_.updateStyleProperty(this,_loc4_.toString());
  292.             }
  293.          }
  294.       }
  295.    }
  296. };
  297. FStyleFormat.prototype.isAStyle = function(name)
  298. {
  299.    return !this.nonStyles[name] ? true : false;
  300. };
  301.